package com.dianping.cat.home.dependency.graph.transform;

import com.dianping.cat.home.dependency.graph.entity.TopologyEdge;
import com.dianping.cat.home.dependency.graph.entity.TopologyGraph;
import com.dianping.cat.home.dependency.graph.entity.TopologyNode;
import org.xml.sax.Attributes;













public class DefaultSaxMaker
  extends Object
  implements IMaker<Attributes>
{
  public TopologyEdge buildTopologyEdge(Attributes attributes) {
    String key = attributes.getValue("key");
/*  26 */     String type = attributes.getValue("type");
/*  27 */     String target = attributes.getValue("target");
/*  28 */     String opposite = attributes.getValue("opposite");
    String weight = attributes.getValue("weight");
/*  30 */     String status = attributes.getValue("status");
    String des = attributes.getValue("des");
    String link = attributes.getValue("link");
/*  33 */     String self = attributes.getValue("self");
/*  34 */     String dashed = attributes.getValue("dashed");
/*  35 */     TopologyEdge topologyEdge = new TopologyEdge(key);

/*  37 */     if (type != null) {
/*  38 */       topologyEdge.setType(type);
    }

/*  41 */     if (target != null) {
/*  42 */       topologyEdge.setTarget(target);
    }

/*  45 */     if (opposite != null) {
/*  46 */       topologyEdge.setOpposite(((Boolean)convert(Boolean.class, opposite, Boolean.valueOf(false))).booleanValue());
    }

/*  49 */     if (weight != null) {
/*  50 */       topologyEdge.setWeight(((Integer)convert(Integer.class, weight, Integer.valueOf(0))).intValue());
    }

/*  53 */     if (status != null) {
/*  54 */       topologyEdge.setStatus(((Integer)convert(Integer.class, status, Integer.valueOf(0))).intValue());
    }

/*  57 */     if (des != null) {
/*  58 */       topologyEdge.setDes(des);
    }

/*  61 */     if (link != null) {
/*  62 */       topologyEdge.setLink(link);
    }

/*  65 */     if (self != null) {
/*  66 */       topologyEdge.setSelf(self);
    }

/*  69 */     if (dashed != null) {
/*  70 */       topologyEdge.setDashed(((Boolean)convert(Boolean.class, dashed, Boolean.valueOf(false))).booleanValue());
    }

/*  73 */     return topologyEdge;
  }


  public TopologyGraph buildTopologyGraph(Attributes attributes) {
    String id = attributes.getValue("id");
/*  79 */     String type = attributes.getValue("type");
/*  80 */     String status = attributes.getValue("status");
/*  81 */     String des = attributes.getValue("des");
/*  82 */     TopologyGraph topologyGraph = new TopologyGraph();

/*  84 */     if (id != null) {
/*  85 */       topologyGraph.setId(id);
    }

/*  88 */     if (type != null) {
/*  89 */       topologyGraph.setType(type);
    }

/*  92 */     if (status != null) {
/*  93 */       topologyGraph.setStatus(((Integer)convert(Integer.class, status, Integer.valueOf(0))).intValue());
    }

/*  96 */     if (des != null) {
/*  97 */       topologyGraph.setDes(des);
    }

/* 100 */     return topologyGraph;
  }


  public TopologyNode buildTopologyNode(Attributes attributes) {
/* 105 */     String id = attributes.getValue("id");
/* 106 */     String type = attributes.getValue("type");
/* 107 */     String status = attributes.getValue("status");
/* 108 */     String des = attributes.getValue("des");
/* 109 */     String link = attributes.getValue("link");
/* 110 */     String weight = attributes.getValue("weight");
/* 111 */     TopologyNode topologyNode = new TopologyNode(id);

/* 113 */     if (type != null) {
/* 114 */       topologyNode.setType(type);
    }

/* 117 */     if (status != null) {
/* 118 */       topologyNode.setStatus(((Integer)convert(Integer.class, status, Integer.valueOf(0))).intValue());
    }

/* 121 */     if (des != null) {
/* 122 */       topologyNode.setDes(des);
    }

/* 125 */     if (link != null) {
/* 126 */       topologyNode.setLink(link);
    }

/* 129 */     if (weight != null) {
/* 130 */       topologyNode.setWeight(((Integer)convert(Integer.class, weight, Integer.valueOf(0))).intValue());
    }

/* 133 */     return topologyNode;
  }


  protected <T> T convert(Class<T> type, String value, T defaultValue) {
/* 138 */     if (value == null || value.length() == 0) {
/* 139 */       return defaultValue;
    }

/* 142 */     if (type == Boolean.class || type == boolean.class)
/* 143 */       return (T)Boolean.valueOf(value); 
/* 144 */     if (type == Integer.class || type == int.class)
/* 145 */       return (T)Integer.valueOf(value); 
/* 146 */     if (type == Long.class || type == long.class)
/* 147 */       return (T)Long.valueOf(value); 
/* 148 */     if (type == Short.class || type == short.class)
/* 149 */       return (T)Short.valueOf(value); 
/* 150 */     if (type == Float.class || type == float.class)
/* 151 */       return (T)Float.valueOf(value); 
/* 152 */     if (type == Double.class || type == double.class)
/* 153 */       return (T)Double.valueOf(value); 
/* 154 */     if (type == Byte.class || type == byte.class)
/* 155 */       return (T)Byte.valueOf(value); 
/* 156 */     if (type == Character.class || type == char.class) {
/* 157 */       return (T)Character.valueOf(value.charAt(0));
    }
/* 159 */     return (T)value;
  }
}


/* Location:              /Users/hanfei/Documents/apache-tomcat-9.0.24/webapps/cat/WEB-INF/classes/!/com/dianping/cat/home/dependency/graph/transform/DefaultSaxMaker.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       1.0.7
 */